<template>
  <div class="dashboard-editor-container">
    <div class=" clearfix">
      <pan-thumb :image="avatar" style="float: left">
        惊不惊喜，意不意外
<!--        Your roles:-->
        <span v-for="item in roles" :key="item" class="pan-info-roles">{{ item }}</span>
      </pan-thumb>
<!--      <github-corner style="position: absolute; top: 0px; border: 0; right: 0;" />-->
      <div class="info-container">
        <span class="display_name">{{ name }}</span>
        <span style="font-size:20px;padding-top:20px;display:inline-block;">早起的鸟儿有肉吃</span>
      </div>
    </div>
    <div>
      <img :src="emptyGif" class="emptyGif">
    </div>
    <div>
      <el-button type="primary" plain>
        <el-link href="https://amazon.55830.cn/common/amazon-auth" target="_blank">授权</el-link>
      </el-button>
      <el-button type="primary" plain @click="refresh_token">刷新令牌</el-button>
      <el-button type="primary" plain @click="seller_msg">卖家信息</el-button>
      <el-button type="primary" plain @click="feeds_product">上传商品xml</el-button>
    </div>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
import PanThumb from '@/components/PanThumb'
import GithubCorner from '@/components/GithubCorner'
import axios from 'axios'
import { getToken } from '@/utils/auth'
export default {
  name: 'DashboardEditor',
  components: { PanThumb, GithubCorner },
  data() {
    return {
      emptyGif: 'https://wpimg.wallstcn.com/0e03b7da-db9e-4819-ba10-9016ddfdaed3'
    }
  },
  computed: {
    ...mapGetters([
      'name',
      'avatar',
      'roles'
    ])
  },
  methods: {
    refresh_token() {
      console.log('refresh_token')
      // axios.get('https://amazon.55830.cn/common/get-access-token')
      axios({
        method: 'get',
        url: 'https://amazon.55830.cn/common/get-access-token',
        data: null,
        headers: { 'HYPERF-SESSION-ID': '6SjgYYpSyIxI64GPQDpGFdCWl5xw0svCV35lXcfd' }
      }).then(function(res) {
        var response = res.data
        if (response.code === 200) {
          this.$message({
            message: response.msg,
            type: 'success'
          })
        } else {
          this.$message({
            message: response.msg,
            type: 'error'
          })
        }
      })
        .catch(function() {
          this.$message({
            message: 'error',
            type: 'error'
          })
        })
    },
    seller_msg() {
      axios({
        method: 'get',
        url: 'https://amazon.55830.cn/common/test-seller',
        data: null,
        headers: { 'HYPERF-SESSION-ID': '6SjgYYpSyIxI64GPQDpGFdCWl5xw0svCV35lXcfd' }
      }).then(function(res) {
        var response = res.data
        if (response.code === 200) {
          this.$message({
            message: response.msg,
            type: 'success'
          })
        } else {
          this.$message({
            message: response.msg,
            type: 'error'
          })
        }
      })
    },
    feeds_product() {
      axios({
        method: 'get',
        url: 'https://amazon.55830.cn/common/feeds-product',
        data: null,
        headers: { 'HYPERF-SESSION-ID': getToken() }
      }).then(function(res) {
        var response = res.data
        if (response.code === 200) {
          this.$message({
            message: response.msg,
            type: 'success'
          })
        } else {
          this.$message({
            message: response.msg,
            type: 'error'
          })
        }
      })
    }
  }
}

</script>

<style lang="scss" scoped>
  .emptyGif {
    display: block;
    width: 45%;
    margin: 0 auto;
  }

  .dashboard-editor-container {
    background-color: #e3e3e3;
    min-height: 100vh;
    padding: 50px 60px 0px;
    .pan-info-roles {
      font-size: 12px;
      font-weight: 700;
      color: #333;
      display: block;
    }
    .info-container {
      position: relative;
      margin-left: 190px;
      height: 150px;
      line-height: 200px;
      .display_name {
        font-size: 48px;
        line-height: 48px;
        color: #212121;
        position: absolute;
        top: 25px;
      }
    }
  }
</style>
